package com.faf.service.impl;

import java.sql.SQLException;

import com.faf.dao.UserDao;
import com.faf.dao.impl.BaseDaoImpl;
import com.faf.dao.impl.UserDaoImpl;
import com.faf.service.UserService;
import com.faf.tools.RSAUtils;



public class UserServiceImpl implements UserService
{
	
	@Override
	public int check(String userNumber,String userPwd) throws SQLException{
		
		UserDaoImpl udi = new UserDaoImpl();
		String udi_UserPassword = null;
		udi_UserPassword = udi.getUserByNumber(userNumber).getUserPassword();
		
		if(udi_UserPassword!=null)
			udi_UserPassword = RSAUtils.privateDecrypt(udi_UserPassword);//这是一个加密操作
		System.out.println("当前密码"+userPwd+"\n实际密码"+udi_UserPassword);
		
		if(userNumber.equals("")){
			return 2;
		}
		if(userPwd.equals("")){
			return -2;
		}
		if(udi_UserPassword==null){
			return -1;
		}
		if(userPwd.equals(udi_UserPassword)){
			return 1;
		}
		else{
			return 0;
		}
    }
	
}
